<?php session_start();
/**
* @package		Parents@School.
* @copyright	Copyright (C) 2008 Kristof Beckers. All rights reserved.
* @Version		1.0
* @license		GNU/GPL, see LICENSE.php
**/

include ("../include/config.php");
require_once ("../include/db.php");
include ("../include/header.php");


if(isset($_SESSION['myusername'])){
$username1 = $_SESSION['myusername'];
$username = explode(".",$username1);
$user = $_SESSION['myusername'];	

$sql = "SELECT ID FROM $tbusers WHERE username='$user'";	
$result = mysql_query($sql);
while ($row=mysql_fetch_array($result)){
	$idreset = $row['ID'];
	}

$passwd1 = $_POST['passwd1'];
$passwd2 = $_POST['passwd2'];
$id = $_GET['id'];



?><head>
<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900" rel="stylesheet" />
<link href="../templates/alicebourg/default.css" rel="stylesheet" type="text/css" media="all" />
<link href="../templates/alicebourg/fonts.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<div id="wrapper">
	<div id="header-wrapper">
    	<div id="header" class="container">
        	<div id="logo">
            <h1>Reservaties ouderavond Alicebourg</h1>
            </div>
        </div>
        <div id="menu" class="container">
        <?php include ("../include/menu.php"); ?>
       </div>

     </div>
     <div id="page" class="container">
  <?php 
if	($passwd1 == ''){
?>
<form name="form1" method="post" action="pwdres.php?id=<?php echo "$idreset" ; ?>">
    Op deze pagina kan u het wachtwoord veranderen voor &quot;<?php echo strtoupper($username[1].' '. $username[2]) ; ?> &quot;  
	<p>Voer het nieuwe wachtwoord in</p>
      <input name="passwd1" type="password" id="passwd1">
      <!--<input name="id" type="hidden" value="<?php echo $idreset ; ?>">-->
    Voer het wachtwoord nogmaals in ter bevestiging
      <input name="passwd2" type="password" id="passwd2">

      <input name="Verstuur" type="submit" id="Verstuur" class="button" value="Verstuur">

 
</form>

<?php
}
else{

	if ($passwd1 != $passwd2){
		
	echo "
De wachtwoorden komen niet overeen <br />
Klik op de onderstaande knop om opnieuw te proberen<br /><br />
<a href='javascript:javascript:history.go(-1)'><img src='../images/go-back.png' width='64' height='64' border='0'></a> <br /><br />";
	}
	else 
	{
	$passwordmd5 = md5($passwd1) ; 
	$sqlupdate = "UPDATE $tbusers SET password = '$passwordmd5' WHERE ID='$id'";
mysql_query($sqlupdate) or die(mysql_error());
?>
<img src="../images/password.jpg" width="64" height="64" border="0"> <br /><br />

Het wachtwoord is aangepast <br /><br />
Klik op de onderstaande knop om opnieuw inloggen<br /><br />
<a href="../login/logout.php"><img src="../images/refresh.png" width="64" height="64" border="0"></a> <br /><br />
<?php
}}

}
?> </div>
</div>
</body>